
import { BaseEntity, Column, Entity, JoinColumn, ManyToOne, OneToMany, OneToOne, PrimaryGeneratedColumn } from "typeorm";
import { OrderEntity } from "./order.entity";
import { RoleEntity } from "./role.entity";

@Entity({ name: 'users' })
export class UsersEntity extends BaseEntity {
    @PrimaryGeneratedColumn()
    id: number;

    @Column({
        type: 'varchar',
        length: 50
    })
    username: string;//用户名

    @Column({
        type: 'varchar',
        length: 50
    })
    password: string;//密码

    @Column({
        type: 'varchar',
        length: 50
    })
    yourname: string;//姓名

    @Column({
        type: 'varchar',
        length: 50
    })
    sex: string;//性别

    @Column({
        type: 'varchar',
        length: 50
    })
    nation: string;//民族


    @Column({
        type: 'varchar',
        length: 50
    })
    phone: string;//电话号码

    @Column({
        type: 'varchar',
        length: 50
    })
    card: string;//身份证号

    @Column({
        type: 'varchar',
        length: 300
    })
    address: string;//下单地点

    @Column({
        type: 'tinyint',
        default: 1
    })
    status: 0 | 1;//0：禁用，1: 启用

    @ManyToOne(
        () => RoleEntity,
        m => m.userEntity
    )
    role: RoleEntity;//用户身份

    order: OrderEntity[] = new Array<OrderEntity>;//用户订单
}